<?php
/*
Template Name: Portfolio  - 1 Column - full width
*/
get_header(); ?>

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); 

    $content = get_the_content();
	$title = get_the_title();

	// Posts per page
	$posts_per_page = get_post_meta($post->ID, 'posts_per_page', true);
	if ( $posts_per_page == '' ) $posts_per_page = '-1';

endwhile; ?>

<?php $portfolios = get_portfolios(); 

foreach ($portfolios as $portfolio):
	if (is_page($portfolio->page)): ?>
	
    	<section id="content_wrapper" class="clearfix">

        	<h1 class="page_title">
                <?php echo $title; ?>
            </h1>
            <div class="page_content">
                <?php the_content(); ?>
            </div><!-- .page_content -->
                            
            <?php
            
            $portfolio_ids = explode(',', $portfolio->category);
    
            $args = array(
                'post_type' => 'portfolios',
				'posts_per_page' => $posts_per_page,
                'tax_query' => array(
                    array(
                        'taxonomy' => 'portfolio_category',
                        'field' => 'id',
                        'terms' => $portfolio_ids
                    )
                ),
				'paged' => $paged
            );
            
            $wp_query = new WP_Query( $args );
    
            global $more;
            $more = 0;
            $post_count = 0;
			
			echo '<div id="portfolio_1_column_full_width_wrapper clearfix">';

            if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post();
                
                if ( has_post_thumbnail() ) $thumbnail_src = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );
                
				$thumbnail_size = 'w=450&amp;h=250';
                $image_source = get_template_directory_uri().'/includes/timthumb.php?src='.$thumbnail_src.'&amp;'.$thumbnail_size.'&amp;zc=1&amp;q=100';
				$image_background_source = get_template_directory_uri().'/includes/timthumb.php?src='.$thumbnail_src.'&amp;'.$thumbnail_size.'&amp;zc=1&amp;q=100&amp;f=2|8|8|8|8|8|8|8';
                            
                echo '<article class="portfolio_full_width clearfix">';

					echo '<a class="portfolio_image" href="'; the_permalink(); echo '">';
						echo '<div class="zoom">';
							echo '<span></span>';
						echo '</div>';
						echo '<div class="on_top" style="background: url(\''; echo $image_source; echo '\');"></div>';
						echo '<div class="on_middle" style="background: url(\''; echo $image_background_source; echo '\');"></div>';
						echo '<div class="above_bottom" style="background: url(\''; echo $image_source; echo '\');"></div>';
						echo '<div class="on_bottom"></div>';
					echo '</a>';
						
					echo '<div class="portfolio_content clearfix">';
						echo '<div class="heading">';
							echo '<a href="'; the_permalink(); echo '">';
								echo '<h3>';
									echo the_title();
								echo '</h3>';
							echo '</a>';
						echo '</div>';
						echo '<div class="text">';
							echo the_content('');
						echo '</div>';
						
						echo '<div class="read_more">';
							echo '<a href="'; the_permalink(); echo '">';
								echo '<span class="read_more_arrow"></span>';
								echo __( 'Read more', 'reFresh' );
							echo '</a>';
						echo '</div>';
						
						echo '<div class="meta clearfix">';
							echo '<div class="date">';
								echo __( 'Posted on: ', 'reFresh' ); echo get_the_date('d M Y'); 
							echo '</div>';
							
							echo '<div class="posted_by">';
								echo __( 'Posted by: ', 'reFresh' );	the_author();
								echo ', Comments: '; comments_number('0', '1', '%');
							echo '</div>';
						echo '</div>';
						
                    echo '</div>'; // .portfolio_content
               echo '</article>';
				
            
            endwhile; endif;
            
			if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
			
            echo '</div>'; // END #portfolio_4_circles
            
            
            ?>

        </section> <!-- #content_wrapper -->

	<?php get_footer();
	
	return; endif;
endforeach;
?>









